//
//  TitleView.m
//  Arts1
//
//  Created by apple on 15/9/6.
//  Copyright (c) 2015年 Arts1. All rights reserved.
//

#import "TitleView.h"
#import "AllHeader.h"
#define WIDTH (SCREEN_WIDTH / 375)
#define HEIGHT (SCREEN_HEIGHT / 667)

@implementation TitleView

- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame])
    {
        [self addSubview:self.btnNum];
        
        [self addSubview:self.button];
        
        _index = 0;
    }
    return self;
}

- (UIButton *)btnNum
{
    if (!_btnNum)
    {
        self.btnNum = [UIButton buttonWithType:UIButtonTypeCustom];
        
        _btnNum.frame = CGRectMake(0, 0, SCREEN_WIDTH / 4.0, 23);
        _btnNum.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft ;
        _btnNum.titleLabel.font = [UIFont boldSystemFontOfSize:18.0];

        
    }
    return _btnNum;
}

- (UIButton *)button
{
    if (!_button)
    {
        self.button = [UIButton buttonWithType:UIButtonTypeCustom];
    
        _button.frame = CGRectMake(0, _btnNum.bottom, SCREEN_WIDTH / 4.0, 9);
        _button.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft ;

        _button.titleLabel.font = [UIFont systemFontOfSize: 10.0];
    }
    return _button;
}

- (void)setIndex:(NSInteger)index{
        _index = index;
        _btnNum.tag = 1050 + _index;
        _button.tag = 1060 + _index;
    if (_index == 1) {
        [_button setTitleColor:kCustomColor(40, 40, 50, 1) forState:(UIControlStateNormal)];
        [_btnNum setTitleColor:kCustomColor(40, 40, 50, 1) forState:(UIControlStateNormal)];
    } else {
        [_button setTitleColor:kCustomColor(155, 155, 155, 1) forState:(UIControlStateNormal)];
        [_btnNum setTitleColor:kCustomColor(155, 155, 155, 1) forState:(UIControlStateNormal)];
    }
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
